package com.nmsl.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.statistic.domain.DailyFlow;
import com.nmsl.statistic.service.IDailyFlowService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 每日流水Controller
 * 
 * @author ruoyi
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/daily/statistic")
public class DailyFlowController extends BaseController
{
    @Autowired
    private IDailyFlowService dailyFlowService;

    /**
     * 查询每日流水列表
     */
    @PreAuthorize("@ss.hasPermi('daily:statistic:list')")
    @GetMapping("/list")
    public TableDataInfo list(DailyFlow dailyFlow)
    {
        startPage();
        List<DailyFlow> list = dailyFlowService.selectDailyFlowList(dailyFlow);
        return getDataTable(list);
    }

    /**
     * 导出每日流水列表
     */
    @PreAuthorize("@ss.hasPermi('daily:statistic:export')")
    @Log(title = "每日流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailyFlow dailyFlow)
    {
        List<DailyFlow> list = dailyFlowService.selectDailyFlowList(dailyFlow);
        ExcelUtil<DailyFlow> util = new ExcelUtil<DailyFlow>(DailyFlow.class);
        util.exportExcel(response, list, "每日流水数据");
    }

    /**
     * 获取每日流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('daily:statistic:query')")
    @GetMapping(value = "/{dailyFlowId}")
    public AjaxResult getInfo(@PathVariable("dailyFlowId") String dailyFlowId)
    {
        return success(dailyFlowService.selectDailyFlowByDailyFlowId(dailyFlowId));
    }

    /**
     * 新增每日流水
     */
    @PreAuthorize("@ss.hasPermi('daily:statistic:add')")
    @Log(title = "每日流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DailyFlow dailyFlow)
    {
        return toAjax(dailyFlowService.insertDailyFlow(dailyFlow));
    }

    /**
     * 修改每日流水
     */
    @PreAuthorize("@ss.hasPermi('daily:statistic:edit')")
    @Log(title = "每日流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DailyFlow dailyFlow)
    {
        return toAjax(dailyFlowService.updateDailyFlow(dailyFlow));
    }

    /**
     * 删除每日流水
     */
    @PreAuthorize("@ss.hasPermi('daily:statistic:remove')")
    @Log(title = "每日流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dailyFlowIds}")
    public AjaxResult remove(@PathVariable String[] dailyFlowIds)
    {
        return toAjax(dailyFlowService.deleteDailyFlowByDailyFlowIds(dailyFlowIds));
    }
}
